<?php

/*
Editing Random Events (admin_edit_events.pro.php)
*/

$rank_check = "7";
include "../global.inc.php";

$explodeEvent = explode(", ", $edit_event);
$countEvent = count($explodeEvent) - 1;

for ($a = 0; $a <= $countEvent;)
{
	if (($type == "cheap_item") OR ($type == "rare_item"))
	{
		$findItem = fetch("SELECT * FROM items2 WHERE item_name = '$explodeEvent[$a]' AND game = '$game'");
		if (!$findItem[id])
		{
			die(header(error("admin_edit_event.php?game=$game&type=$type","The item \"$explodeEvent[$a]\" does 	not exsist!")));
		}
	}
	if ($type == "points")
	{
		if ($explodeEvent[$a] <= 0)
		{
			die(header(error("admin_edit_event.php?game=$game&type=$type","This event only allows values greater 	then 0. Remember, this event is for Point Prizes, not items!")));
		}
	}
	$a++;
}

if ($type == "points") { mysql_query("UPDATE random_events SET point_event = '$edit_event' WHERE game = '$game'"); }
if ($type == "cheap_item") { mysql_query("UPDATE random_events SET cheap_item_event = '$edit_event' WHERE game = '$game'"); }
if ($type == "rare_item") { mysql_query("UPDATE random_events SET rare_item_event = '$edit_event' WHERE game = '$game'"); }
if ($type == "talking") { mysql_query("UPDATE random_events SET talking_event = '$edit_event' WHERE game = '$game'"); }

header("Location: admin_edit_event.php?game=$game&error=The+event+was+edited!&type=$type");

?>
